gapminder_file <- "https://raw.githubusercontent.com/COMBINE-Australia/RNAseq-R/gh-pages/data/gapminder-FiveYearData.csv"
download.file(gapminder_file, destfile="gapminder-FiveYearData.csv")
gapminder <- read.csv("gapminder-FiveYearData.csv")
library("ggplot2")
ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp)) 

ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp)) +  geom_point()

ggplot(data = gapminder, aes(x = year, y = lifeExp)) + geom_point()

ggplot(data = gapminder, aes(x = year, y = lifeExp, color=continent)) +
  geom_point()

ggplot(data = gapminder, aes(x=year, y=lifeExp, by=country, color=continent)) +
  geom_line()

ggplot(data = gapminder, aes(x=year, y=lifeExp, by=country, color=continent)) +
  geom_line() + geom_point()

ggplot(data = gapminder, aes(x=year, y=lifeExp, by=country)) +
  geom_line(aes(color=continent)) + geom_point()

ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp, color=continent)) +   geom_point()

ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp, color=continent)) + geom_point(alpha = 0.1) + scale_x_log10() + facet_wrap(~continent)

ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp)) +
  geom_point() + scale_x_log10() + geom_smooth(method="lm")

ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp)) +
  geom_point(color="orange", size=4) + scale_x_log10() + geom_smooth(method="lm", size=0.5)

ggplot(data = gapminder, aes(x = gdpPercap, y = lifeExp, color = continent)) +
geom_point(size=3, shape=17) + scale_x_log10() +
geom_smooth(method="lm", size=1.5)

starts.with <- substr(gapminder$country, start = 1, stop = 1)
az.countries <- gapminder[starts.with %in% c("C", "U"),  ]
ggplot(data = az.countries, aes(x = year, y = lifeExp, color=continent)) +   geom_line() + facet_wrap( ~ country)